﻿// <copyright project="Salient.SqlServer.FluentNHibernate" file="SqlGeographyUserTypeConvention.cs" company="Sky Sanders">
// This source is a Public Domain Dedication.
// Please see http://spikes.codeplex.com/ for details.   
// Attribution is appreciated
// </copyright> 
// <version>1.0</version>

using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.AcceptanceCriteria;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.Instances;
using Microsoft.SqlServer.Types;
using Salient.SqlServer.NHibernate;

namespace Salient.SqlServer.FluentNHibernate
{
    public class SqlGeographyUserTypeConvention : UserTypeConvention<SqlGeographyUserType>
    {
        public override void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
        {
            criteria.Expect(x => x.Property.PropertyType == typeof (SqlGeography));
        }

        public override void Apply(IPropertyInstance instance)
        {
            instance.CustomType(typeof (SqlGeographyUserType));
        }
    }
}